// 企业发布职位
import React, { Component } from 'react'
import {
    View,
} from 'react-native';

import { ForPublishAction } from '../../actions/postion_c';      //加载action
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import Cpublishpro_top from './cpublishpro_top'
import Cpublishpro_body from './cpublishpro_body'

class Cpublishpro_all extends Component {
    // 初始化模拟数据
    constructor(props) {            //构造器只执行一次
        super(props);
    };

    //加载后渲染页面
    componentDidMount() {
        this.props.actions.ForPublishAction(); //初始化查询
    }

    render() {
        const { xzPostion, state } = this.props.xzPostion.data;
        return (
            <View style={{ backgroundColor: "#f6f6f6", flex: 1, }}>
                <Cpublishpro_top navigation={this.props.navigation} />
                <Cpublishpro_body xzPostion={xzPostion} state={state} navigation={this.props.navigation} />
            </View>
        )
    }
}

//组合action
var actions = {
    ForPublishAction
}

//连接state到props
const mapStateToProps = state => {
    return {
        xzPostion: state.ForPublishReducer
    }
}

//连接action
const mapDispatchToProps = (dispatch) => {
    return {
        actions: bindActionCreators(actions, dispatch)
    }
}

//导出组合好的组件(组合后状态改变重新渲染组合组件的页面)
export default connect(
    mapStateToProps, mapDispatchToProps
)(Cpublishpro_all);